package oop;

/**
 * @author: knowno
 * @create: 2025-09-11 10:48
 * @Version 1.0
 **/
public class Animal {
    public void eat(){
        System.out.println("动物吃");
    }
    public void sleep(){
        System.out.println("动物睡");
    }
    public void perform(){
        System.out.println("动物表演");
    }

}

class Dog extends Animal{
    @Override
    public void eat(){
        System.out.println("狗吃骨头");
    }
    @Override
    public void sleep(){
        System.out.println("狗趴着睡");
    }

    @Override
    public void perform() {
        System.out.println("小狗表演抓飞盘");
    }
}

class Tiger extends  Animal{
    @Override
    public void perform() {
        //表示的调用父类的实例方法, super代指父类对象
        super.perform();
        System.out.println("老虎表演钻火圈");
    }
}

class Zoo {

    public static void perform(Animal animal){
        //从这里引用名来看,调用的是父类引用方法
        //但是实际运行的是子类的方法(取决于传递过来的对象是哪个子类的对象)
        animal.perform();
    }

}
